package com.example.common.response;

/**
 * 响应状态枚举
 * Created with IntelliJ IDEA.
 * author: zjl
 * Date: 2020/9/3
 * Time: 11:37
 */
public enum ServerCode {

    /**
     * 全局
     */
    SUCCESS(1000, "请求成功"),
    SYSTEM_ERROR(1001, "系统紧急修复，请稍后重试"),
    PARAMETER_ERROR(1002, "请求参数错误"),
    RESPONSE_ERROR(1003, "响应数据错误"),
    NO_DATA(1004, "查无数据"),
    CONCURRENT_ERROR(1005,"数据已过时，请重新获取数据后重试");


    private int code;

    private String desc;

    ServerCode(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ServerCode getInstance(int code) {
        for (ServerCode entity : ServerCode.values()) {
            if (entity.getCode() == code) {
                return entity;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
